home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PRINTER / PROHP.ARJ / DLPI.PRG < prev    next >
Text File  |  1992-06-23  |  4KB  |  123 lines

  1. /*
  2.   ┌─────────────────────────────────────────────────────────────────────────┐
  3.   │                                                                         │
  4.   │    Program : lpi.PRG                                                    │
  5.   │                                                                         │
  6.   │    Purpose : demonstrate the use of HP_lpi() using SIZEBYROWCOL.        │
  7.   │                                                                         │
  8.   │   Author  : Copyright (C) 1992, I.L.A.,Inc. All Rights reserved.        │
  9.   │                                                                         │
  10.   │   Comments: This source code may be distributed and used freely         │
  11.   │             provided that the copyright notice is not removed.          │
  12.   │                                                                         │
  13.   └─────────────────────────────────────────────────────────────────────────┘
  14.  
  15. */
  16. #include "prohp.ch"
  17.  
  18. proc main()
  19. Local cTestLine := "Text Line in Box.",i,nHeight
  20. Local nBoxH:=4,nBoxW:=3, nLm := 0.2
  21. Local nTop:=0.3, nLeft1:=0.3,nLeft2:=nBoxW+0.5
  22. Local cText,nColW,nLc
  23. set2print("dlpi.hpc")
  24. HP_init()
  25. HP_send(.t.)
  26.  HP_pitch(10)    // courier 10
  27.  HP_lpi(6)        // 6 LPI
  28. HPshadow(.t.)      // shadow boxes is nicer
  29.  
  30.  HP_box(nTop,nLeft1,nBoxH,nBoxW)      // draw box 1
  31.  HP_box(nTop,nLeft2,nBoxH,nBoxW)      // draw box 2
  32.  
  33.  HP_setpos(nTop,nLeft1)          // absolute cursor position to box 1
  34. prbox(nBoxH,nLeft1+nLm)       // Print at all line in box
  35.  
  36.  HP_setpos(nTop,nLeft2)  // absolute cursor position to box 2
  37.  HP_pitch(16)    // courier 16
  38.  HP_lpi(10)        // set 10 LPI
  39.  
  40. // Print at all line in box and set the proper left margin
  41. prbox(nBoxH,nLeft2+nLm)
  42. nTop+= nBoxH +0.5
  43. nBoxH /= 2
  44. //nBoxW /= 2
  45.  HP_box(nTop,nLeft1,nBoxH,nBoxW)      // draw box
  46.  HP_pitch(10)
  47. cText := "If the human race wishes to have a prolonged and "+;
  48. "indefinite period of material prosperity, they have only got to "+;
  49. "behave in a peaceful and helpful way toward one another, and "+;
  50. "science will do for them all they wish and more than they can "+;
  51. "dream. "+chr(13)+chr(10)+"        -Winston Churchill"
  52.  
  53. // find how many columns in nBoxW
  54. nColW := HPi2col(nBoxW-nLm)     //  * HP_data(D_CPI)
  55.  
  56. // Find how many lines in cText
  57. nLc:= mlcount(cText,nColW)
  58.  
  59. // Set LPI to fit the entire box height - bottom margin of 0.1"
  60.  HP_lpi(nLc /(nBoxH-0.1))
  61.  
  62. // print the text in box
  63.  HP_setpos(nTop,nLeft1+nLm)
  64. for i:=1 to nLc
  65.     HP_rcpos(1,,.t.) // one line down
  66.      HP_setpos(,nLeft1+nLm)  // move to left margin
  67.     qqout(memoline(cText,nColW,i))
  68. next
  69.  
  70. /*
  71.   now we will fit the box size to the text set Width and Height
  72.   will be calculating according to the current LPI
  73. */
  74.  HP_pitch(16)
  75. // find how many columns in nBoxW
  76. nColW := HPi2col(nBoxW-nLm)     //  * HP_data(D_CPI)
  77. // Find how many lines in cText
  78. nLc:= mlcount(cText,nColW)
  79.  
  80. /*
  81.    change the next LPI setting to see how the following
  82.    code will adjust itself to the new setting.
  83. */
  84.  HP_lpi(8)
  85.  
  86. // Set nBoxH to hold all lines of text
  87. nBoxH := HProw2i(nLc)+0.1  // add 0.1" for bottom margin
  88. // draw filled box as background to the text
  89. HPsetshadow(,GFILLBLACK) // make dark shadow
  90.  HP_fillbox(nTop,nLeft2,nBoxH,nBoxW,,GFILLGRAY,10)
  91.  HP_setpos(nTop,nLeft2+nLm)
  92. for i:=1 to nLc
  93.     HP_rcpos(1,,.t.) // one line down
  94.      HP_setpos(,nLeft2+nLm)  // move to left margin
  95.     qqout(memoline(cText,nColW,i))  // print the line
  96. next
  97. /*
  98.   Now we leave you with the chalange to find the Width of a box
  99.   to hold cText when you have LPI and Height .
  100. */
  101.  HP_reset()
  102. set2screen()
  103. return
  104.  
  105. proc Prbox(nHeight,nLeftMargin)
  106. Local cTestLine:="And The Oscar Goes to ",i
  107.  HP_savecsr()
  108. // draw separation lines
  109. For i:=1 to nHeight*HP_data(D_LPI)
  110.      HP_rcpos(1,,.t.)   // move one line down
  111.      HP_setpos(,nLeftMargin)
  112.      HP_rline(0.01,HPstsize(cTestLine+str(i,2)),GFILLGRAY,60)
  113. next
  114.  HP_restcsr()
  115. // print text in box
  116. For i:=1 to nHeight*HP_data(D_LPI) -1
  117.     HP_rcpos(1,,.t.)        // move one line down
  118.     HP_setpos(,nLeftMargin)  // move to left margin
  119.     qqout(str(i,2),cTestLine)    // print string
  120. next
  121. return
  122.  
  123.